-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix macro hygiene bug #32923
Merged
Merged
Fix macro hygiene bug #32923
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closed
This could use a crater run (cf. discussion in #32922). |
Starting a crater run |
alexcrichton
added
the
S-waiting-on-crater
Status: Waiting on a crater run to be completed.
label
Apr 14, 2016
Crater reports one regression, but it looks spurious, so essentially nothing from crater. |
Great, thanks! |
Could you add some of the tests from #31856 please? r+ with that |
@bors: r+ |
📌 Commit ca1d29c has been approved by |
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
Apr 15, 2016
Fix macro hygiene bug This fixes rust-lang#32922 (EDIT: and fixes rust-lang#31856), macro hygiene bugs. It is a [breaking-change]. For example, the following would break: ```rust fn main() { let x = true; macro_rules! foo { () => { let x = 0; macro_rules! bar { () => {x} } let _: bool = bar!(); //^ `bar!()` used to resolve the first `x` (a bool), //| but will now resolve to the second x (an i32). }} foo! {}; } ``` r? @nrc
Fixes #10681. |
Fixes #26223. |
bluss
added
relnotes
Marks issues that should be documented in the release notes of the next release.
and removed
S-waiting-on-crater
Status: Waiting on a crater run to be completed.
labels
Jun 9, 2016
bors
added a commit
that referenced
this pull request
Jun 23, 2016
Fix macro hygiene regression The regression was caused by #32923, which is currently in beta. The following is an example of regressed code: ```rust fn main() { let x = 0; macro_rules! foo { () => { println!("{}", x); // prints `0` on stable and after this PR, prints `1` on beta and nightly } } let x = 1; foo!(); } ``` For code to regress, the following is necessary (but not sufficient): - There must be a local variable before a macro in a block, and the macro must use the variable. - There must be a second local variable with the same name after the macro. - The macro must be invoked in a statement position after the second local variable. For example, if the `let x = 0;` from the breaking example were commented out, it would (correctly) not compile on beta/nightly. If the semicolon were removed from `foo!();`, it would (correctly) print `0` on beta and nightly. r? @nrc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #32922 (EDIT: also #31856, #10681, and #26223), macro hygiene bugs.
It is a [breaking-change]. For example, the following would break:
r? @nrc